package com.yc.ui.admin;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DateTime;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;

import com.yc.ui.LoginItem;
import com.yc.ui.LoginUI;
import com.yc.ui.MainUI;
import com.yc.ui.dialog.MoneyDialog;
import com.yc.utils.ControlUtil;
import com.yc.utils.DataDict;
import com.yc.utils.SWTUtil;

public class Manager {

	protected Shell shell;
	public static Composite composite_1;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Manager window = new Manager();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(1087, 765);
		shell.setText("摸鱼客栈");
		shell.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		shell.setImage(SWTResourceManager.getImage(Manager.class, "/com/yc/images/小图标鱼.PNG"));
		
		SashForm sashForm = new SashForm(shell, SWT.VERTICAL);
		SWTUtil.centerWindow(shell);
		
		Composite composite = new Composite(sashForm, SWT.NONE);
		composite_1 = new Composite(sashForm, SWT.NONE);
		composite.setBackgroundImage( SWTResourceManager.getImage(MainUI.class, "/com/yc/images/主界面按钮框.PNG") );
		SWTUtil.imagetSize(composite);
		composite.setLayout(null);
		
		Button but = new Button(composite, SWT.NONE);
		but.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				DataDict.stackLayout.topControl = DataDict.Room;//默认顶层显示
				composite_1.layout();//刷新
			}
		});
		but.setBounds(10, 10, 104, 104);
		but.setText("客房查询");
		ControlUtil.circleControl(but);
		
		Button but_1 = new Button(composite, SWT.NONE);
		but_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				DataDict.stackLayout.topControl = DataDict.Users;
				composite_1.layout();//刷新
				
			}
		});
		but_1.setText("会员信息");
		but_1.setBounds(141, 10, 104, 104);
		ControlUtil.circleControl(but_1);
		
		Button but_2 = new Button(composite, SWT.NONE);
		but_2.setText("管理员信息");
		but_2.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				DataDict.stackLayout.topControl = DataDict.MaInfoUI;
				composite_1.layout();//刷新
			}
		});
		but_2.setBounds(279, 10, 104, 104);
		ControlUtil.circleControl(but_2);
		
		Button but_3 = new Button(composite, SWT.NONE);
		but_3.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				DataDict.stackLayout.topControl = DataDict.Good;
				composite_1.layout();//刷新
			}
		});
		but_3.setText("商品信息");
		but_3.setBounds(418, 10, 105, 105);
		ControlUtil.circleControl(but_3);
		
		Button but_4 = new Button(composite, SWT.NONE);
		but_4.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				DataDict.stackLayout.topControl = DataDict.LMessage;
				composite_1.layout();//刷新
			}
		});
		but_4.setText("评价回复");
		but_4.setBounds(691, 10, 105, 105);
		ControlUtil.circleControl(but_4);
		
		Button but_6 = new Button(composite, SWT.NONE);
		but_6.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				DataDict.stackLayout.topControl = DataDict.AdminLoginItem;
				composite_1.layout();//刷新
			}
		});
		but_6.setText("信息消费");
		but_6.setBounds(555, 10, 105, 105);
		ControlUtil.circleControl(but_6);
		
		DateTime dateTime = new DateTime(composite, SWT.BORDER);
		dateTime.setBounds(851, 47, 176, 40);
		
		
		sashForm.setWeights(new int[] {1, 5});
		
		composite_1.setLayout(DataDict.stackLayout);//给右侧面板设置堆栈式布局
		AdminLoginItem adminloginItem = new AdminLoginItem(composite_1, SWT.NONE);
		DataDict.AdminLoginItem = adminloginItem;
		DataDict.LMessage = new LMessage(composite_1, SWT.NONE);
		DataDict.Users = new Users(composite_1, SWT.NONE);
		DataDict.MaInfoUI = new MaInfoUI(composite_1, SWT.NONE);
		DataDict.Good = new Good(composite_1, SWT.NONE);
		//自定的层叠面板
		AdminRoom adminroom = new AdminRoom(composite_1, SWT.NONE);
		adminroom.setSize(535, 596);
		DataDict.Room  = adminroom;
		
		DataDict.stackLayout.topControl = DataDict.Room;//默认顶层显示
	}

}
